<html>
<head><meta charset="utf-8"><title>What directory are UI tests run from? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html">What directory are UI tests run from?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232617284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232617284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232617284">(Mar 31 2021 at 16:02)</a>:</h4>
<p>For <a href="https://github.com/rust-lang/rust/pull/83705">https://github.com/rust-lang/rust/pull/83705</a>, I need to pass an argument to a file which exists (which file doesn't matter). Originally I tried just passing the source file itself, but that gave a file not found error, I think because the relative paths are wrong. Is there a way to see what directory the tests are run from? Or does compiletest set any variables I could use?</p>



<a name="232617341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232617341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232617341">(Mar 31 2021 at 16:02)</a>:</h4>
<p>I don't want to use <code>/etc/passwd</code> or something because that will break on windows</p>



<a name="232617758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232617758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232617758">(Mar 31 2021 at 16:04)</a>:</h4>
<p>Maybe use a run-make test?</p>



<a name="232617775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232617775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232617775">(Mar 31 2021 at 16:04)</a>:</h4>
<p>I tried <code>$DIR</code> but apparently it doesn't get replaced in <code>compile-flags</code>?</p>



<a name="232617849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232617849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232617849">(Mar 31 2021 at 16:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/What.20directory.20are.20UI.20tests.20run.20from.3F/near/232617758">said</a>:</p>
<blockquote>
<p>Maybe use a run-make test?</p>
</blockquote>
<p>hmm but I'd like to test the error output</p>



<a name="232617962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232617962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232617962">(Mar 31 2021 at 16:06)</a>:</h4>
<p>I guess I could just use grep and manually add a .stderr file to compare it too, but then --bless won't work</p>



<a name="232618731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232618731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232618731">(Mar 31 2021 at 16:10)</a>:</h4>
<p>compiletest itself doesn't seem to set the current working directory, so I am guessing that the dir from which <code>x.py</code> is run is used as current working directory. This dir doesn't have to be root of the local rust checkout, so you shouldn't rely on it.</p>



<a name="232618777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232618777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232618777">(Mar 31 2021 at 16:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/What.20directory.20are.20UI.20tests.20run.20from.3F/near/232617775">said</a>:</p>
<blockquote>
<p>I tried <code>$DIR</code> but apparently it doesn't get replaced in <code>compile-flags</code>?</p>
</blockquote>
<p>I think implementing this is the best option.</p>



<a name="232619017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232619017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232619017">(Mar 31 2021 at 16:12)</a>:</h4>
<p>hmm ok I see the issue, right now compiletest only normalizes <em>outputs</em>, not inputs</p>



<a name="232619455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232619455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232619455">(Mar 31 2021 at 16:14)</a>:</h4>
<p>I need to set <code>test_cx.props.compile_flags</code> looks like</p>



<a name="232619609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232619609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232619609">(Mar 31 2021 at 16:15)</a>:</h4>
<p>oh ffs</p>
<div class="codehilite"><pre><span></span><code>fn expand_variables(mut value: String, config: &amp;Config) -&gt; String {
    const CWD: &amp;str = &quot;{{cwd}}&quot;;
    const SRC_BASE: &amp;str = &quot;{{src-base}}&quot;;
    const BUILD_BASE: &amp;str = &quot;{{build-base}}&quot;
</code></pre></div>
<p>it decided to use its own variables <span aria-label="face palm" class="emoji emoji-1f926" role="img" title="face palm">:face_palm:</span></p>



<a name="232619788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232619788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232619788">(Mar 31 2021 at 16:16)</a>:</h4>
<p>ok yup <code>// compile-flags:--theme {{src-base}}/invalid-theme-name.rs</code> does what I want</p>



<a name="232620147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232620147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232620147">(Mar 31 2021 at 16:18)</a>:</h4>
<p>do you understand this error?</p>
<div class="codehilite"><pre><span></span><code>---- [ui] rustdoc-ui/invalid-theme-name.rs stdout ----

error: error pattern &#39;invalid argument: &quot;/home/joshua/rustc3/src/test/rustdoc-ui/invalid-theme-name.rs&quot;&#39; not found!
status: exit status: 1

stderr:
------------------------------------------
error: invalid argument: &quot;/home/joshua/rustc3/src/test/rustdoc-ui/invalid-theme-name.rs&quot;
</code></pre></div>



<a name="232620258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232620258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232620258">(Mar 31 2021 at 16:19)</a>:</h4>
<p>ok well changing it to just <code>invalid-argument</code> made it work so we're going with that <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="232621450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20directory%20are%20UI%20tests%20run%20from%3F/near/232621450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20directory.20are.20UI.20tests.20run.20from.3F.html#232621450">(Mar 31 2021 at 16:26)</a>:</h4>
<p><a href="https://github.com/rust-lang/rustc-dev-guide/pull/1098">https://github.com/rust-lang/rustc-dev-guide/pull/1098</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>